package com.itheima.order.service;

import com.itheima.feign.clien.UserClien;
import com.itheima.feign.pojo.User;
import com.itheima.order.mapper.OrderDao;
import com.itheima.order.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：xiaoZhou
 * @ClassName : OrderServiceImpl
 * @date ：Created in 2021/12/14 22:42
 */
@Service
public class OrderServiceImpl implements OrderService{

    @Autowired
    private OrderDao orderDao;

    @Autowired
    private UserClien userClien;

    @Override
    public Order findOrderById(Long id) {
        Order order = orderDao.findOrderById(id);

        //通过order获取user的id
        User user = userClien.findById(order.getUserId());

        order.setUser(user);

        return order;
    }
}
